<template>
	<div class="">
		<form class="form-cont" v-show="!riskShow">
			<div class="form-baseinput">
				<div class="form-group formline labellarge">
					<label>事故黑点地点：</label>
					<input type="text" class="form-control" v-model="list.jarSite" placeholder="事故黑点地点">
				</div>
				<div class="form-group formline labellarge">
					<label>现场限速数值：</label>
					<input type="number" class="form-control" v-model="list.jarSpeed" placeholder="现场限速数值">
				</div>
				<div class="form-group formline labellarge jranoedit">
					<label>主要风险：</label>
					<p class="stateTask" @click="getRisk">
						{{list.baseInfo.riskCategorisation}}
						<i class="ion ion-ios-arrow-right"></i>
					</p>	
				</div>
				<div class="form-group formline labellarge jranoedit">
					<label>风险分析：</label>
					<p class="stateTask">
						{{list.baseInfo.riskAnalysis}}
					</p>	
				</div>
				<div class="form-group formline labellarge jranoedit">
					<label>控制措施：</label>
					<p class="stateTask">
						{{list.baseInfo.controlMeasures}}
					</p>	
				</div>
			</div>

	      <div class="totleandok clearFix">
	        <!-- <p v-if="$parent.chooseOnly == 1">共选择 {{totlePersion}} 人</p> -->
	         <button type="button" @click="backParent">返回</button>
	        <button type="button" class="shureok" @click="chooseOk">确定</button>
	      </div>
	      <loading v-if="loadShow"></loading>
	      <toast v-if="toastShow" :message="tipMessage"></toast>
		</form>
		<risk-list v-if="riskShow"></risk-list>
	</div>
</template>
<script type="text/javascript">

import riskList from '../../components/safereport/riskList'
import http from '../../assets/js/http_mixin'

	export default{
		data(){
			return {
				list:{
					jarSite:'',
					jarSpeed:'',
					baseInfo:{
						riskCategorisation:'请选择',
						riskAnalysis:'',
						controlMeasures:''
					},
				},
				riskShow:false
			}
		},
		components:{riskList},
		mounted() {

		},
		mixins:[http],
		methods:{
			getRisk() {
				this.riskShow = true			
			},
			backParent() {
				this.$parent.isShow = false;
			},
			chooseOk() {
				if(!this.list.jarSite){
					this.toastShow = true;
		            this.tipMessage = '请填写事故黑点地点';
		            setTimeout(()=>{
		                this.toastShow = false;
		            },1500);
		            return ;
				}
				if(!this.list.jarSpeed){
					this.toastShow = true;
		            this.tipMessage = '请填写现场限速数值';
		            setTimeout(()=>{
		                this.toastShow = false;
		            },1500);
		            return ;
				}
		        if(!this.list.baseInfo.riskCategorisation || this.list.baseInfo.riskCategorisation == '请选择'){
		            this.toastShow = true;
		            this.tipMessage = '请选择主要风险';
		            setTimeout(()=>{
		                this.toastShow = false;
		            },1500);
		            return ;
		        }
				let listRisk = {
					jarSite:this.list.jarSite,
					jarSpeed:this.list.jarSpeed,
					jarRisk:this.list.baseInfo.riskCategorisation,
					jarAnalsis:this.list.baseInfo.riskAnalysis,
					jarControl:this.list.baseInfo.controlMeasures
				};
				if(listRisk.jarSite && listRisk.jarSpeed){
					this.$parent.items.push(listRisk);
					this.$parent.isShow = false;
				}
			}

		}
	}
</script>